from selenium.webdriver.common.by import By
#导入类对象
from common.Ultils import BlogDriver

class BlogList:
    driver = ""
    url=""
    def __init__(self):
        self.url="http://8.137.19.140:9090/blog_list.html"
        self.driver=BlogDriver.driver
        self.driver.get(self.url)
    #测试博客首页（在登录状态下）
    def ListTestByLogin(self):
        #测试博客的页面标题
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div:nth-child(1) > div.title")
        #测试博客内容
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div:nth-child(1) > div.desc")
        #测试博客按钮是否存在
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div:nth-child(1) > a")
        #检测昵称是否存在
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.left > div > h3")
        #……
        #测试博客的头像是否出现
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.left > div > img")
        #添加截屏操作
        BlogDriver.getScreeShot()

        # self.driver.quit()
    #测试博客首页（在未登录状态下）
    def ListTestByNoLogin(self):
        username=self.driver.find_element(By.CSS_SELECTOR,"#username").text
        password=self.driver.find_element(By.CSS_SELECTOR,"#password").text
        assert username=="" and password==""






